export default function (fileId: any): any {
  const exportData: any = {
    fileId,
    url: '/zdcommon/fileUpload/download'
  }
  downLoadFile(exportData)
}

const downLoadFile = (params: any): any => {
  const _reportForm = document.createElement('form')
  document.body.appendChild(_reportForm) // 加入到body中
  _reportForm.method = params.responseType || 'get'
  _reportForm.action = '/prod-api' + params.url
  _reportForm.target = '_blank'

  if (typeof params === 'object') {
    for (const key in params) {
      // 遍历json对象的每个key/value对
      const paraElement = document.createElement('input')
      paraElement.setAttribute('name', key)
      paraElement.setAttribute('type', 'hidden')
      paraElement.setAttribute('value', params[key])
      _reportForm.appendChild(paraElement)
      // console.log('文件输出', params, _reportForm.action, _reportForm)
    }
    _reportForm.submit()
    setTimeout(() => {
      document.body.removeChild(_reportForm)
      // _reportForm = null;
    })
  }
}

// import qhCodeSwitch from '@/utils/qhCode'
